package cc.shacocloud.luanniao.core.service.text.extract.pdf

import cc.shacocloud.luanniao.core.service.text.extract.FileContentExtractService
import org.apache.pdfbox.Loader
import org.apache.pdfbox.text.PDFTextStripper
import java.io.File

/**
 * pdf 文件内容提取服务实现
 *
 * @author 思追(shaco)
 */
class PdfFileContentExtractServiceImpl : FileContentExtractService {

    override fun extract(file: File): String {
        return Loader.loadPDF(file).use { doc ->
            val stripper = PDFTextStripper()
            stripper.getText(doc)
        }
    }

}